<template>
  <el-form :inline="true" :model="position" class="form-inline">
    <el-row class="row">
      <el-form-item label="当班人员：">
        <el-input
          v-model="formInline.userName"
          placeholder="--请输入--"
        ></el-input>
      </el-form-item>
      <el-form-item label="当班时间：">
        <el-date-picker
          v-model="date"
          type="daterange"
          format="YYYY-MM-DD "
          value-format="YYYY-MM-DD "
          range-separator="~"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          @change="dateChange"
          size="small"
        />
      </el-form-item>
      <el-form-item class="btns">
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="success" class="m-left" @click="onClear"
          >清空</el-button
        >
      </el-form-item>
    </el-row>
  </el-form>
</template>

<script setup>
import { reactive, defineEmits, ref } from 'vue'
const formInline = reactive({
  userName: '', //当班人员
  time: '' //时间选择
})
const date = ref([])
const dateChange = (date) => {
  formInline.time = date
}
const emits = defineEmits(['onSearch'])
const onSubmit = () => {
  emits('onSearch', formInline)
}
const onClear = () => {
  formInline.userName = ''
  formInline.time = ''
  date.value = []
  emits('onSearch', formInline)
}
</script>

<style lang="scss" scoped>
.form-inline {
  margin-top: 15px;
  width: 100%;
  position: relative;
  // display: flex;
  column-gap: 20px;
  // padding-bottom: 33px;
  // margin-top: -5px;
  .row {
    display: flex;
    flex-wrap: wrap;
    column-gap: 5%;
  }
  .btns {
    position: absolute;
    right: 0;
    top: 4px;
    .m-left {
      margin-left: 20px;
    }
  }
}
</style>
